package com.cxf.windex.rest.admin;

import com.cxf.windex.base.msg.TableResultResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.BShopBiz;
import com.cxf.windex.entity.BShop;
import com.cxf.windex.entity.JsType;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: business_needs
 * @description: 店铺管理
 * @author: chenxf
 * @create: 2018-10-11 16:46
 **/
@Api(tags = {"村广通[后台] - 店铺管理"})
@Controller
@RequestMapping("admin/shop")
public class AdminShopController extends BaseRestController<BShopBiz,BShop> {
  @ApiOperation(value = "查询店铺", notes = "查询店铺")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "limit", value = "记录数 默认10", required = false, paramType = "query", dataType = "int"),
      @ApiImplicitParam(name = "offset", value = "页码 默认 1", required = false, paramType = "query", dataType = "int"),
      @ApiImplicitParam(name = "orderStr", value = "排序 默认desc", required = false, paramType = "query", dataType = "String"),
      @ApiImplicitParam(name = "name", value = "类型名称", required = false, paramType = "query", dataType = "String"),
  })
  @RequestMapping(value = "/list", method = RequestMethod.GET)
  @ResponseBody
  public TableResultResponse<BShop> list(
      @RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,
      @RequestParam(defaultValue = "desc") String orderStr,  String name) {
    List<BShop> items = baseBiz.list(limit, offset, orderStr,  name);
    PageInfo<BShop> pageInfo = new PageInfo<BShop>(items);
    return new TableResultResponse<BShop>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
        offset, limit,
        items);
  }
}
